﻿#region Using References

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using Beaker.OpenCube.CubeManager.Model.Framework;
using Beaker.OpenCube.CubeManager.Model.Interfaces;

#endregion

namespace Beaker.OpenCube.CubeManager.Model.Entities
{
	public class Role
		: Entity, INamed
	{
		private readonly EntitySet<RoleSet, Role> _roleSets;
		private readonly EntitySet<Activity, Role> _activities;

		public Role( string roleName )
			: this()
		{
			Name = roleName;
		}

		internal Role()
		{
			_roleSets = new EntitySet<RoleSet, Role>( this, roleSet => roleSet.Roles );
			_activities = new EntitySet<Activity, Role>( this, activity => activity.Roles );
		}

		/// <summary>
		/// Gets or sets the name of this role.
		/// </summary>
		/// <value>
		/// The name of this role.
		/// </value>
		[StringLength( 64 )]
		[Required]
		public string Name { get; internal set; }

		/// <summary>
		/// Gets the set of activities assigned to this role.
		/// </summary>
		/// <value>
		/// The activities assigned to this role.
		/// </value>
		public ISet<Activity> Activities
		{
			get { return _activities; }
		}

		/// <summary>
		/// Gets the set of rolesets that contain this role
		/// </summary>
		/// <value>
		/// The set of rolesets that contain this role
		/// </value>
		public ISet<RoleSet> RoleSet
		{
			get { return _roleSets; }
		}
	}
}
